#include <stdio.h>
#include "SceneGraph.h"

Group::Group(){
	next = 0;
}

void Group::add(Node *n){
	if(next == sizeof(children)-1){
		printf("Error! No room for more children\n");
		return;
	}
	
	for(int i = 0; i < next; i++){
		if(children[i] == n){
			printf("Error! Child already in childlist\n");
			return;
		}
	}
	children[next] = n;
	next += 1;
}

void Group::remove(Node *n){
	for(int i = 0; i < next; i++){
		if(children[i] == n){
			children[i] == children[next-1];
			next -= 1;
			return;
		}
	}
	printf("Error! Node was not removed\n");
}

void Group::draw(Matrix4 *C, Texture *t) {
	for(int i = 0; i < next; i++){
		children[i]->draw(C, t);
		children[i]->animateEnabled = animateEnabled;
	}
}


